package com.mcx.modules;

import java.util.ArrayList;

public class PlayerMgr {

    private PlayerMgr()
    {
        m_AllRole = new ArrayList<PlayerEntity>();
    }

    // 单例
    private static Object lock_object = new Object();
    private static PlayerMgr instance;

    public static PlayerMgr getInstance()
    {
        if (instance == null)
        {
//            lock(lock_object)
            {
                if (instance == null)
                {
                    instance = new PlayerMgr();
                }
            }
        }
        return instance;
    }

    private ArrayList<PlayerEntity> m_AllRole;
    public ArrayList<PlayerEntity> getAllRole(){
        return m_AllRole;
    }

    public PlayerEntity GetRole(int roleId)
    {
        for (int i = 0; i < m_AllRole.size(); i++)
        {
            if (m_AllRole.get(i).id == roleId) return m_AllRole.get(i);
        }
        return null;
    }
}
